<?php

$con = mysql_connect("localhost","root","root");
if (!$con)
  {
  die('Could not connect: ' . mysql_error());
  }

mysql_select_db("comds", $con);
$dateTime = date("Y-m-d",strtotime("-1 day"));


error_reporting(E_ALL ^ E_NOTICE);
 //FUNCTION: Connect to PostgreSql database
 
 //create a connection to postgresql database
set_time_limit(0);
ini_set("memory_limit", "200M");
  pg_connect("host=localhost dbname=comds  user=root  password=root")
   or die('Could not connect:'.pg_last_error());
  $dateTime = date("Y-m-d",strtotime("-1 day"));
  $update_query = pg_query("select totalexp,firstlogintime,totaldollorget,todaygametime,todaytcrystallose,crystal,todaygoldget,todaygoldlose,cracked,weaponlist,todayexp,todayiapinfo,gold,level,gameactivetime,totalgoldget,uilastid,hireoutselftimes,totalgametime,todaytcrystalget,deviceid,gamename,whatday,createdate,date from comds where date = '$dateTime'");

while($update = pg_fetch_assoc($update_query))
{
   mysql_query("INSERT INTO comds (TotalExp,FirstLoginTime,FirstLogin,TotalDollorGet,TodayGameTime, TodayTCrystalLose,Crystal,TodayGoldGet, TodayGoldLose,Cracked,WeaponList,TodayExp,TodayIapInfo,
                                          Gold,Level,GameActiveTime,TotalGoldGet, UILastId,HireoutSelfTimes,TotalGameTime,TodayTCrystalGet, deviceid,gamename,createdate,date
                                         ) 
                    VALUES('$update[totalexp]','$update[firstlogintime]','$update[firstlogintime]','$update[totaldollorget]','$update[todaygametime]','$update[todaytcrystallose]','$update[crystal]','$update[todaygoldget]','$update[todaygoldlose]','$update[cracked]','$update[weaponlist]','$update[todayexp]','$update[todayiapinfo]','$update[gold]',
                           '$update[level]','$update[gameactivetime]','$update[totalgoldget]','$update[uilastid]','$update[hireoutselftimes]','$update[totalgametime]','$update[todaytcrystalget]','$update[deviceid]','$update[gamename]','$update[createdate]','$update[createdate]'
                         
                      )") or die(mysql_error());
}

  
  // $del = pg_num_rows($del_query);

//mysql_query("DELETE FROM dinocap2hd WHERE whatday < '2012-03-15' or whatday >'$dateTime'");

//pg_close($con);
?>